package com.cc.self.service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.cc.self.dao.SelfFactoryDao;
import com.cc.self.model.raw.SelfFactory;


@Service(value = "com.cc.self.service.SelfFactoryService")
public class SelfFactoryService {
	@Autowired
	private SelfFactoryDao aSelfFactoryDao;

	/**
	 * 根据组织查询列表
	 * @param bus_id 自营主键
	 * @return List<SelfFactory>
	 */
	public List<SelfFactory> getSelfFactoryList(Integer bus_id) {
		Map<String, Object> p = new HashMap<String, Object>();
		p.put("bus_id", bus_id);

		List<SelfFactory> list = aSelfFactoryDao.getSelfFactoryList(p);

		return list;
	}

	/**
	 * 获取实体
	 * @param id 主键
	 * @return SelfFactory
	 */
	public SelfFactory getSelfFactory(int id) {
		Map<String, Object> p = new HashMap<String, Object>();
		p.put("id", id);
		List<SelfFactory> l = aSelfFactoryDao.getSelfFactoryList(p);
		return l.size() > 0 ? l.get(0) : null;
	}

	/**
	 * 创建实体
	 * @param SelfFactory 实体信息
	 * @return SelfFactory 实体信息
	 */
	public SelfFactory createSelfFactory(SelfFactory entity) {
		aSelfFactoryDao.createSelfFactory(entity);
		return entity;
	}
	
	/**
	 * 修改实体
	 * @param SelfFactory 实体信息
	 * @return SelfFactory 实体信息
	 */
	public SelfFactory updateSelfFactory(SelfFactory entity) {
		aSelfFactoryDao.updateSelfFactory(entity);
		return entity;
	}
	
	/**
	 * 删除实体
	 * @param SelfFactory 实体信息
	 * @return SelfFactory 实体信息
	 */
	public SelfFactory deleteSelfFactory(SelfFactory entity) {
		deleteSelfFactory(entity.getId());
		return entity;
	}
	
	/**
	 * 删除实体
	 * @param id 主键
	 * @return id 主键
	 */
	public int deleteSelfFactory(int id) {
		aSelfFactoryDao.deleteSelfFactory(id);
		return id;
	}

}

